<?
/**
*  通过电话号码定位客户
*  2013/7/15, by zh
*/
session_start();
session_cache_limiter('private');
session_cache_expire(60*12);
header("P3P: CP='ALL ADM DEV PSAi COM OUR OTRo STP IND ONL'");

if(empty($_GET['telephone']) || empty($_GET['agent'])) {
	exit;
}

include("../webkit/include/simple_db.php");
$db = new SimpleDB();

$telephone = $_GET['telephone'];  // 主叫或被叫号
$agent = $_GET['agent'];   // 座席工号

$_SESSION['call_number'] = $telephone; 
$_SESSION['is_agent'] = "yes";  
$_SESSION['uid'] = $agent;  
$_SESSION['user_flag'] = 'admin';  // 将座席工号标识为管理角色

$sql = "select id, client_name from jx_client where mobilephone='$telephone' or telephone1='$telephone' or telephone2='$telephone' or telephone3='$telephone'";
$rec = $db->getOneRecord($sql);

if($rec == null) {
	header("location:order_list.php"); // 没有找到指定客户记录;
} else {
	$client_id = $rec['id'];
	header("location:order_list.php?client_id=$client_id&client_name=".urlencode($rec['client_name'])."&telephone=$telephone"); 
}
?>